package cn.com.huzo.repository.master.impl;

import cn.com.huzo.model.entities.master.ExchangeRateEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import cn.com.huzo.repository.master.ExchangeRateRepository;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 汇率数据访问对象。
 *
 * @author 范学春
 */
@Repository("ExchangeRateRepository")
public class ExchangeRateRepositoryImpl extends GenericRepositoryImpl<ExchangeRateEntity, Long>
        implements ExchangeRateRepository {

    private final String namespace = "cn.com.huzo.repository.master.ExchangeRateRepository";

    /**
     * 构造函数,设置the entity to ContractReviewHeaderRepositoryImpl.class.
     */
    public ExchangeRateRepositoryImpl() {
        super(ExchangeRateEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ExchangeRateEntity fetchByKey(Long key) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByKey"), key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> criterion) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<ExchangeRateEntity> fetchForPage(Map<String, Object> criterion) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchInsert(List<ExchangeRateEntity> itemList) {
        // 影响的行数
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchInsert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchUpdate(List<ExchangeRateEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchUpdate"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(Long key) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), key);
    }
}
